<%= title "User Settings".html_safe -%>

<div id='settings' class='grid_12 boxit page'>

	<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { :method => :put, :multipart => true, :class => 'basic-form validate' }) do |f| %>
	  <%= devise_error_messages! %>

		<div id='form-holder' class=''>

			<div class='grid_5'>

				<% if Snorby::CONFIG[:authentication_mode] == "cas" %>
  				<p><%= f.label :name %> <em>(please use your complete CAS login)</em><br />
  			  <%= f.text_field :name, :placeholder => 'CAS login', :class => 'required' %></p>
        <% else %>
  				<p><%= f.label :name %> <em>(please use first and last name)</em><br />
  			  <%= f.text_field :name, :placeholder => 'Full Name', :class => 'required' %></p>
        <% end %>

			  <p><%= f.label :email %> <em>(example: snorby@example.com)</em><br />
			  <%= f.text_field :email, :placeholder => 'E-mail Address', :class => 'required email' %></p>

        <% if Snorby::CONFIG[:authentication_mode] == "database"  %>
  				<p><%= f.label :password %> <em>(leave blank if you don't want to change it)</em><br />
  			  <%= f.password_field :password, :placeholder => 'Password' %></p>

  			  <p><%= f.label :password_confirmation %><br />
  			  <%= f.password_field :password_confirmation, :placeholder => 'Password Confirmation' %></p>

  				<p><%= f.label :current_password %> <em>(we need your current password to confirm your changes)</em><br />
  			  <%= f.password_field :current_password, :placeholder => 'Current Password', :class => 'required password' %></p>

  				<p>
  			<% end %>
					<%= f.label 'Note Notifications:' %>
					<%= f.select :accept_notes, [['Yes', 1], ['No', 2], ['Only events I\'ve noted', 3]], { :include_blank => false } %><br />
					<em>(Would you like to receive notifications when new notes are added?)</em><br />
					<br />
				</p>

				<p>
					I would like to list <%= f.select :per_page_count, %w[25 45 65 100], { :include_blank => false } %>  <%= f.label "items per page." %><br />
					<em>(select the default amount of events to list per page view)</em><br />
					<br />
				</p>

			</div>

			<div class='grid_5 alpha'>

				<div class='user-show-avatar'>

					<%= image_tag(get_gravatar_uri(@user.email), :class => 'avatar') %>

					<p><strong>Login Count:</strong> <%= @user.sign_in_count %></p>

					<p><strong>Current Login IP:</strong> <%= @user.current_sign_in_ip || 'N/A' %></p>


					<p><strong>Last Login:</strong> <%= @user.updated_at.strftime('%a %b, %Y %I:%M %p %Z') %></p>

					<p><strong>Last Login IP:</strong> <%= @user.last_sign_in_ip || 'N/A' %></p>

					<p><strong>Queued Event Count:</strong> <%= @user.favorites_count %></p>

					<p><strong>Notes Count:</strong> <%= @user.notes_count %></p>

				</div>

        <p>
          <em>(To change/add a avatar please visit <a href="http://gravatar.com">http://gravatar.com</a>)</em>
        </p>

        <p>
          <%= f.label 'Time Zone:' %>
          <%= f.time_zone_select :timezone, ActiveSupport::TimeZone.us_zones %>
        </p>

        <p>
          <%= f.check_box :email_reports %> <%= f.label 'Event Summary Report:' %>
          <br />
          <em>(Would you like to receive an event summary report every 30 minutes)</em><br />
        </p>

				<% if current_user.admin? %>

					<p>
						<%= f.check_box :admin %> <%= f.label "Administrator" %>
						<em>(should this user have administrative rights?)</em>
					</p>

				<% end %>

			</div>

		</div>

		<%= form_actions do %>

			<%= button "Update Settings", :class => 'success' %>

			<%= button "Cancel", :class => 'warning cancel' %>

		<% end %>

	<% end %>

</div>
